define(['app'], function(app) {
	'use strict';

	var controller = function controller($scope, Mypointdetail, $timeout) {
		
		//初始化页面
		$scope.init_data = function(){
			Mypointdetail.getPointList(1,function(data){
				$scope.pointList = data.point;
				$scope.tPage = data.page.tPage;
				console.log($scope.tPage)
			})
		}
		$scope.init_data();
		
		/****************上下拉刷新****************/
		$scope.nPage = 1;
		$scope.isLoad = false; //可以加载
		$scope.doRefresh = function() {
			//防止重复加载
			$scope.isLoad = true;
			Mypointdetail.getPointList(1, function(data) {
				$scope.pointList = data.point;
				$scope.nPage = 1;
			},
			function() {
				$scope.$broadcast('scroll.refreshComplete');
				$timeout(function() {
					$scope.isLoad = false;
				}, 1500);
			});
		};
		//加载更多
		$scope.doRefreshMore = function() {
			//防止重复加载
			$scope.isLoad = true;
			Mypointdetail.getPointList($scope.nPage + 1, function(data) {
				if(data != null) {
					if($scope.pointList != undefined) {
						$scope.pointList = $scope.pointList.concat(data.point);
						$scope.nPage += 1;
					} else {
						$scope.pointList = data.point;
					}
				}
			},function() {
				$scope.$broadcast('scroll.infiniteScrollComplete');
				$timeout(function() {
					$scope.isLoad = false;
				}, 1500);
			});
		};
		/****************上下拉刷新****************/
		
		
	}

	controller.$inject = ['$scope', 'Mypointdetail', '$timeout'];

	return app.registerController("mypointdetailctrl",controller);
});